package com.marst.first.config;


import com.marst.first.interceptor.AdminInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Author Administrator
 * @Date 2021/10/12 0012 下午 10:14
 * @Description TODO
 * @Version 1.0
 **/
@Configuration
public class InterceptorConfig implements  WebMvcConfigurer{

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        //白名单
        InterceptorRegistration registration = registry.addInterceptor(new AdminInterceptor());
        registration.addPathPatterns("/**");                      //所有路径都被拦截
        registration.excludePathPatterns("/user/login");    //不拦截路径
    }
}
